<template>
<view>
	<!-- 头部 -->
	<view v-if="showuid">
		<view class="d-waikuang-10 d-shang-20">
			<u-row
				customStyle="margin-bottom: 10px"
				gutter="10"
			>
				<u-col span="12">
					<view class="demo-layout bg-purple d-neirong-juzhong">
						<image v-if="member" :src="yonghuXinxi.avatar" mode="aspectFill" class="d-img-40 d-yuanjiao-50 d-beijing-hui"></image>
						<image v-else src="/static/assets/images/avatar.png" mode="aspectFill" class="d-img-40 d-yuanjiao-50 d-beijing-hui"></image>
						<view class="d-wenzi-yanse-hui d-ziti-12">{{yonghuXinxi.name}}</view>
					</view>
				</u-col>
			</u-row>
		</view>
		<!--关注-->
		<view class="d-kuan">
			<view class="d-waikuang-10 ">
				<view class="d-kuan d-yuanjiao-10">
					<view class="d-neikuang-10">
						<view class="d-kuan-25 d-zuo d-neirong-juzhong">
							<view class="d-jiacu">{{yonghuXinxi.score}}</view>
							<view class="d-wenzi-14 d-wenzi-yanse-hui">成长值</view>
						</view>
						<view class="d-kuan-25 d-zuo d-neirong-juzhong">
							<view class="d-jiacu">{{yonghuXinxi.guanzhu_count}}</view>
							<view class="d-wenzi-14 d-wenzi-yanse-hui">关注</view>
						</view>
						<view class="d-kuan-25 d-zuo d-neirong-juzhong">
							<view class="d-jiacu">{{yonghuXinxi.fensi_count}}</view>
							<view class="d-wenzi-14 d-wenzi-yanse-hui">粉丝</view>
						</view>
						<view class="d-kuan-25 d-zuo d-neirong-juzhong">
							<view class="d-jiacu">{{yonghuXinxi.tiezi_count}}</view>
							<view class="d-wenzi-14 d-wenzi-yanse-hui">动态</view>
						</view>
						<view class="d-clear"></view>
					</view>
				</view>
			</view>
		</view>
		<!--会员幻灯-->
		<u-swiper
			:list="viptu"
			previousMargin="30"
			nextMargin="30"
			circular
			:autoplay="false"
			radius="5"
			bgColor="#f4f4f4"
		></u-swiper>
		<!--社区-->
		<view class="d-kuan">
			<view class="d-waikuang-10 ">
				<view class="d-kuan d-yuanjiao-10 d-beijing-bai">
					<view class="d-neikuang-10">
						
						<view class="d-kuan-25 d-zuo d-neirong-juzhong d-shangxia-10">
							<image src="/static/images/img/fabu.png" class="d-img-50"></image>
							<view class="d-wenzi-14 ">帖子</view>
							<view class="d-wenzi-14 d-wenzi-yanse-hui">{{yonghuXinxi.tiezi_count}}条</view>
						</view>
						<view class="d-kuan-25 d-zuo d-neirong-juzhong d-shangxia-10">
							<image src="/static/images/img/shoucang.png" class="d-img-50"></image>
							<view class="d-wenzi-14 ">收藏</view>
							<view class="d-wenzi-14 d-wenzi-yanse-hui">{{yonghuXinxi.shoucang_count}}个</view>
						</view>
						<view class="d-kuan-25 d-zuo d-neirong-juzhong d-shangxia-10">
							<image src="/static/images/img/dianzan.png" class="d-img-50"></image>
							<view class="d-wenzi-14 ">点赞</view>
							<view class="d-wenzi-14 d-wenzi-yanse-hui">{{yonghuXinxi.dianzan_count}}个</view>
						</view>
						<view class="d-kuan-25 d-zuo d-neirong-juzhong d-shangxia-10">
							<image src="/static/images/img/pinglun.png" class="d-img-50"></image>
							<view class="d-wenzi-14 ">评论</view>
							<view class="d-wenzi-14 d-wenzi-yanse-hui">{{yonghuXinxi.pinglun_count}}个</view>
						</view>
						<view class="d-kuan-25 d-zuo d-neirong-juzhong d-shangxia-10">
							<image src="/static/images/img/duanxin.png" class="d-img-50"></image>
							<view class="d-wenzi-14 ">短信</view>
							<view class="d-wenzi-14 d-wenzi-yanse-hui">{{yonghuXinxi.duanxin_count}}个</view>
						</view>
						<view class="d-kuan-25 d-zuo d-neirong-juzhong d-shangxia-10">
							<image src="/static/images/img/qianbao.png" class="d-img-50"></image>
							<view class="d-wenzi-14 ">钱包</view>
							<view class="d-wenzi-14 d-wenzi-yanse-hui">{{yonghuXinxi.money}}</view>
						</view>
						<view class="d-kuan-25 d-zuo d-neirong-juzhong d-shangxia-10">
							<image src="/static/images/img/goumai.png" class="d-img-50"></image>
							<view class="d-wenzi-14 ">已购买</view>
							<view class="d-wenzi-14 d-wenzi-yanse-hui">0个</view>
						</view>
						<view class="d-clear"></view>
		
					</view>
				</view>
			</view>
		</view>
	</view>
	<view v-else>
		<view class="d-kuan d-neikuang-10">
			
			<view class="u-content">
				<view class="u-content__circle">
					<u-icon
						name="checkbox-mark"
						color="#fff"
						size="30"
					></u-icon>
				</view>
				<text class="u-content__normal">跳转登录</text>
			</view>
		</view>
	</view>
	
</view>
</template>

<script>
import toubu from "@/components/toubu/toubu";  //引入头部组件
import config from "../../utils/config";
var Api = require("../../utils/api.js");
var util = require("../../utils/util.js");

var wxApi = require("../../utils/wxApi.js");
var wxRequest = require("../../utils/wxRequest.js");
var webSiteName = config.getWebsiteName;
var domain = config.getDomain;

export default {
  data() {
    return {
      text: "我的",
      categoriesList: {},
      floatDisplay: "none",
      userInfo: {},
      webSiteName: webSiteName,
      domain: domain,
	  www: [],
	  quanlist: [],
	  member: [],
	  show: false,
	  showuid: false,
	  yonghuXinxi: [],
	  viptu:[
			'https://duixin.cc/viptu/haibao.jpg',
			'https://duixin.cc/viptu/haibao2.jpg',
			'https://duixin.cc/viptu/haibao3.jpg',
		]
    };
  },

  components: {
	  toubu,
  },
  props: {},
  onLoad: function (options) {
	var self = this; 
    this.getWww();
	this.getQuanList();
    uni.setNavigationBarTitle({
      title: '我的'
    });
	//判断用户是否登录
	var userInfo = uni.getStorageSync('userInfo');
	if (userInfo) {
		this.showuid = true;
		var member = uni.getStorageSync('member');
		var memberuid = uni.getStorageSync('memberuid');
		
		// 保留二次开发
		self.getYonghuXinxi(memberuid);
	} else {
		//否则跳转到登录页面
		uni.reLaunch({ url: '/pages/login/login'}) // 跳转到首页
	}


  },
  onShow: function () {},
  onShareAppMessage: function () {
    return {
      title: '分享“' + config.getWebsiteName + '”我的.',
      path: 'pages/quanzi/wode',
      success: function (res) {// 转发成功
      },
      fail: function (res) {// 转发失败
      }
    };
  },
  methods: {
	//获取站点
	getWww() {
	  	var self = this;
	  	self.setData({
	  	  www: []
	  	});
	  	var getTubiaoRequest = wxRequest.getRequest(Api.getWwwUrl());
	  	getTubiaoRequest.then(response => {
	  		if (response.data.code == 1) {
	  		  //console.log(response.data.data); 
	  		  self.www = response.data.data
	  		} else {
	  		  self.setData({
	  			displaySwiper: "none"
	  		  });
	  		}
	  	});
	},
	//获取圈子列表
	getQuanList() {
	  	var self = this;
	  	self.setData({
	  	  quanlist: []
	  	});
	  	var getQuanListRequest = wxRequest.getRequest(Api.getQuanlistUrl());
	  	getQuanListRequest.then(response => {
	  		if (response.data.code == 1) {
	  		  //console.log(response.data.data); 
	  		  self.quanlist = response.data.data
	  		} else {
	  		  self.setData({
	  			displaySwiper: "none"
	  		  });
	  		}
	  	});
	},

    reloadData: function (id) {
      var self = this;
      var newCategoriesList = [];
      var categoriesList = self.categoriesList;

      for (var i = 0; i < categoriesList.length; i++) {
        if (categoriesList[i].id == id) {}

        newCategoriesList.push(categoriesList[i]);
      }

      if (newCategoriesList.length > 0) {
        self.setData({
          categoriesList: newCategoriesList
        });
      }
    },
    //跳转至某分类下的文章列表
    redictIndex: function (e) {
      //console.log('查看某类别下的文章');  
      var id = e.currentTarget.dataset.id;
      var name = e.currentTarget.dataset.item;
      var url = '../list/list?categoryID=' + id;
      uni.navigateTo({
        url: url
      });
    },
	// 点击
	quanzi(tieid) {
		console.log('点击',tieid); 
		var url = '../quanzi/quanzi?&id='+tieid;
		uni.navigateTo({
			url: url
		});
	},
	//会员信息
	getYonghuXinxi(uid) {
		var self = this; 
		self.setData({
		  yonghuXinxi: []
		});
		
		var getYonghuXinxiRequest = wxRequest.getRequest(Api.getYonghuXinxi(uid));
		getYonghuXinxiRequest.then(response => {
			if (response.data.code == 1) {
			  
			  self.yonghuXinxi = response.data.data
			} else {
			  self.setData({
				displaySwiper: "none"
			  });
			}
		});
	},
	
  }
};
</script>
<style>
@import "./quan.css";
page {
	background-color: #f3f4f7;
}
</style>